<?php
namespace App\Http\Controllers\Safe;

use App\Http\Controllers\Controller;
use App\Utils\GDUtil;
use App\Utils\SSUtil;
use Illuminate\Http\Request;

/**
 * 后台通用API控制器
 */
class CommonController extends Controller
{
    /**
     * 获取验证码API接口
     */
    public function getYzmCode(Request $request)
    {
        $code = GDUtil::makeCode(5);
        if (intval($request->type) == 1) {
            SSUtil::put([GDUtil::YZM_ADMIN_CODE => $code['code']]);
        } elseif (intval($request->type) == 2) {
            SSUtil::put([GDUtil::YZM_USER_CODE => $code['code']]);
        }
        imagepng($code['img']);
        imagedestroy($code['img']);
    }
}